<?php
class Department{
	
	//Public variables for the smarty template 
	public $mName;
	public $mDescription;

	//Private members 
	private $_mDepartmentId;
	private $_mCategoryId;
	
	public function __construct(){
		//We need to have department id in the query string
		if(isset($_GET['DepartmentId'])){
			$this->_mDepartmentId =(int)$_GET['DepartmentId'];
		}else{
			trigger_error('Department Id Not Set');
		}
		
		// If category Id is in the Query String
	    if(isset($_GET['CategoryId'])){
			$this->_mCategoryId =(int)$_GET['CategoryId'];
		}
	}
		
	public function init(){
		
		//If visiting the department .....
		$department_details =Catalog::GetDepartmentDetails($this->_mDepartmentId);
		//print_r($department_details);
		
	    $this->mName =$department_details['name'];
		$this->mDescription =$department_details['description'];
		
		if(isset($this->_mCategoryId)){
			
			$category_details =Catalog::GetCategoryDetails($this->_mCategoryId);
			
			$this->mName =$category_details['name'];
		    $this->mDescription =$category_details['description'];
			 
		}
		
		
	}		
	
}